/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import view.Principal;

/**
 *
 * @author Edison Parra
 */
public final class ActualUser {

    /**Singleton object. References the data of the user logged in.
     */
    private static ActualUser instance;
    /**Username of the user logged in.
     */
    private String username;
    /**References the main window of the application.
     */
    private Principal principal;
    /**Id of the user.
     */
    private long id;
    /**Balance of the user.
     */
    private double balance;
    /**Balance on change of the user.
     */
    private double balanceOnChange;

    /**Obtain de instance of the Singleton ActualUser.
     * @return The principal object.
     */
    public Principal getPrincipal() {
        return principal;
    }

    /**Set the Principal object to the ActualUser instance.
     * @param newPrincipal The new principal object
     */
    public void setPrincipal(final Principal newPrincipal) {
        this.principal = newPrincipal;
    }

    /**Default Constructor.
     */
    private ActualUser() {
    }

    /**Returns the information of the user logged.
     *@return ActualUser
     */
    public static synchronized ActualUser getInstance() {
        if (instance == null) {
            instance = new ActualUser();
        }
        return instance;
    }

    /**Sets the new instance's values.
     *@param newUn New Username's value
     *@param newId New Id's value
     * @param newBalance New Balance's value
     */
    public void setInstance(final String newUn, final long newId, final double newBalance) {
        instance.username = newUn;
        instance.id = newId;
        instance.balance = newBalance;
    }

    /**Sets the instance in NULL.
     */
    public void setNull() {
        instance = null;
    }

    /**Getter for the Id attribute.
     * @return The id's value
     */
    public long getId() {
        return id;
    }

    /**Setter for the Id attribute.
     * @param newId The new Id's value
     */
    public void setId(final long newId) {
        this.id = newId;
    }

    /**Getter for the Username attribute.
     *  @return The username's value
     */
    public String getUsername() {
        return username;
    }

    /**Setter for the Username attribute.
     * @param newUsername The new Username's value
     */
    public void setUsername(final String newUsername) {
        this.username = newUsername;
    }

    /**Getter for the Balance attribute.
     *  @return The balance's value
     */
    public double getBalance() {
        return balance;
    }

    /**Setter for the Balance attribute.
     * @param newBalance The new Balance's value
     */
    public void setBalance(final double newBalance) {
        this.balance = newBalance;
    }

    /**Getter for the BalanceOnChange attribute.
     *  @return The BalanceOnChange's value
     */
    public double getBalanceOnChange() {
        return balanceOnChange;
    }

    /**Setter for the BalanceOnChange attribute.
     * @param newBalanceOnChange The new Balance on Change's value
     */
    public void setBalanceOnChange(final double newBalanceOnChange) {
        this.balanceOnChange = newBalanceOnChange;
    }
}
